package com.atguigu.flink.chapter05.transform;

import com.atguigu.flink.chapter05.function.WaterSensorMapFunction;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class ReduceDemo2 {
    public static void main(String[] args) {
        Configuration conf = new Configuration();
        conf.setInteger("rest.port",2000);
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(conf);
        env.setParallelism(1);
        //不同sensor的水位和

        env.readTextFile("C:\\IDEA\\code\\LearnDemo\\flink\\input\\sensor.txt")
                .map(new WaterSensorMapFunction())
                .keyBy(ws -> "a")
                .sum("vc")
                .print();

        try {
            env.execute();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}


//public class ReduceDemo2 {
//    public static void main(String[] args) {
//        Configuration conf = new Configuration();
//        conf.setInteger("rest.port",2000);
//        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(conf);
//        env.setParallelism(1);
//        //不同sensor的水位和
//
//        env.readTextFile("C:\\IDEA\\code\\LearnDemo\\flink\\input\\sensor.txt")
//                .map(new WaterSensorMapFunction())
//                .keyBy(ws -> "a")
//                .sum("vc")
//                .print();
//
//        try {
//            env.execute();
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
//}